package com.tomcat;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class HttpResponse {
    private Socket socket;

    private String respHeader = "HTTP/1.1 200 OK\r\n" +
            "Content-Type: text/html;charset=utf-8\r\n\r\n";

    public HttpResponse(Socket socket) {
        this.socket = socket;
    }

    public void writer(String resMessage) {
        try {
            OutputStream outputStream = socket.getOutputStream();
            String senderMessage = respHeader + resMessage;
            outputStream.write(senderMessage.getBytes());
            outputStream.flush();
            outputStream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}